package main

import (
	"WebFacade/aggs"
	"WebFacade/config"
	"WebFacade/log"
	"WebFacade/model"
	"WebFacade/service"
	"WebFacade/sys"
	"WebFacade/tools"
)

func main() {
	// 初始化配置
	config.Init()

	// 初始化工具包
	tools.Init()

	// 初始化日志系统
	log.Init(
		config.Config.Server.Environment,
		config.Config.Server.ServiceName,
	)

	// 初始化存储数据库
	model.Init(
		false,
		config.Config.Mysql.UserName,
		config.Config.Mysql.PassWord,
		config.Config.Mysql.Host,
		config.Config.Mysql.Port,
		config.Config.Mysql.DbName,
		config.Config.Mysql.Debug,
		config.Config.Mysql.Salve,

		false,
		config.Config.Redis.Host,
		config.Config.Redis.Port,
		config.Config.Redis.PassWord,
		config.Config.Redis.DB,
		config.Config.Redis.PoolSize,

		false,
		config.Config.Mongo.Host,
		config.Config.Mongo.Port,
		config.Config.Mongo.DBName,
		config.Config.Mongo.AuthDB,
		config.Config.Mongo.UserName,
		config.Config.Mongo.Password,
		config.Config.Mongo.Auth,

		false,
		config.Config.ES.URL,

		config.Config.Server.Environment,
	)

	// 初始化聚合层
	aggs.Init()

	// 初始化服务组件
	service.Init(
		config.Config.Web.Port,
	)

	// 阻塞主线程
	sys.WaitSysSignal(
		config.Config.Server.ServiceName,
	)
}
